package cn.stylefeng.guns.modular.fi.utils;

import cn.stylefeng.guns.modular.fi.entity.FiCarrierFreightInfo;
import cn.stylefeng.guns.modular.fi.model.params.FiCarrierFreightInfoParam;

import java.math.BigDecimal;

public class YunFeiUtils {

    /**
     * 计算总费用
     * @param fiCarrierFreightInfoParam
     * @return
     */
    public static BigDecimal getSumMoney(FiCarrierFreightInfoParam fiCarrierFreightInfoParam){
        BigDecimal sumMoney = new BigDecimal("0");
        //运费
        if(fiCarrierFreightInfoParam.getFreightMoney() != null){
            sumMoney = sumMoney.add(fiCarrierFreightInfoParam.getFreightMoney());
        }
        //客诉
        if(fiCarrierFreightInfoParam.getCustComplaint() != null){
            sumMoney = sumMoney.subtract(fiCarrierFreightInfoParam.getCustComplaint());
        }
        //其他罚款
        if(fiCarrierFreightInfoParam.getOtherFines() != null){
            sumMoney = sumMoney.subtract(fiCarrierFreightInfoParam.getOtherFines());
        }
        //其他补贴
        if(fiCarrierFreightInfoParam.getOtherSubsidie() != null){
            sumMoney = sumMoney.add(fiCarrierFreightInfoParam.getOtherSubsidie());
        }
        //装车费
        if(fiCarrierFreightInfoParam.getLoadingMoney() != null){
            sumMoney = sumMoney.add(fiCarrierFreightInfoParam.getLoadingMoney());
        }
        return sumMoney;
    }

    public static BigDecimal getSumMoney(FiCarrierFreightInfo fiCarrierFreightInfo){
        BigDecimal sumMoney = new BigDecimal("0");
        //运费
        if(fiCarrierFreightInfo.getFreightMoney() != null){
            sumMoney = sumMoney.add(fiCarrierFreightInfo.getFreightMoney());
        }
        //客诉
        if(fiCarrierFreightInfo.getCustComplaint() != null){
            sumMoney = sumMoney.subtract(fiCarrierFreightInfo.getCustComplaint());
        }
        //其他罚款
        if(fiCarrierFreightInfo.getOtherFines() != null){
            sumMoney = sumMoney.subtract(fiCarrierFreightInfo.getOtherFines());
        }
        //其他补贴
        if(fiCarrierFreightInfo.getOtherSubsidie() != null){
            sumMoney = sumMoney.add(fiCarrierFreightInfo.getOtherSubsidie());
        }
        //装车费
        if(fiCarrierFreightInfo.getLoadingMoney() != null){
            sumMoney = sumMoney.add(fiCarrierFreightInfo.getLoadingMoney());
        }
        return sumMoney;
    }
}
